﻿@model Article
@{  
    var article = new ArticleWrapper(Model);
    var context = WebSiteContext.Current;
    var web = context.Web;
    var _content = article.GetGlobalizationContent();  
}
<div id="viewContent_bodyArea" class="d-post-body">
    @if (Model.ContentFormat == 2)
    {
        @TextEngine.Wiki(_content.Body, topicCssClass: "d-topic")
        Html.RegisterStartupScript("var _topic=$('.d-topic'); if (_topic.length) { _topic.dtree(); _topic.before(\"<b>Content table</b>\");}");
    }
    else
    { 
        @MvcHtmlString.Create(_content.Body)
    }
    <p>
        &nbsp;</p>
    <hr />
    <ul class="d-horizontal-list">
        <li>
            <div>@Ajax.Dna().Rating("ViewRatings").Value(Convert.ToInt16(Model.Ratings)).Changed("$.post('" + Url.Action("Vote", "Article", new { Area="publishing"}) + "',{id:'" + Model.ID + "',value:value});").GetHtml()
                <span style="margin-left: 5px;">
                    @Html.Global("publishing", "Average"):@string.Format("{0:#.#}", Model.Ratings)</span></div>
        </li>
        <li>
            @Ajax.Dna().Link("javascript:void(0);").LocText("publishing", "Reads").ImageIcons(Url.Content("~/Content/Images/notes.gif")).GetHtml()
            <span>(@Model.TotalReads)</span> </li>
        @if (Model.AllowPingback)
        {
            <li>
                @Ajax.Dna().Link("javascript:void(0);").Name("Trackbacklink").LocText("publishing", "Trackback").ImageIcons(Url.Content("~/Content/Images/cloud.gif")).GetHtml()
                <span>(@Model.Comments.Count(c => c.IsTrackback))</span>
                <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
                    <rdf:description rdf:about="@article.PermaLink" dc:identifier="@article.PermaLink" dc:title="@Model.Title" trackback:ping="@article.TrackbackUrl" />
                </rdf:rdf>
                @{ 
            Ajax.Dna().Dialog(Html.Global("publishing", "Trackback"))
                .OpenWith("Trackbacklink")
                .Options(opts =>
                {
                    opts.Width = 300;
                    opts.ShowModal = true;
                    opts.ShowEffect = jQueryEffects.Scale;
                    opts.HideEffect = jQueryEffects.Scale;
                    opts.IsResizable = false;
                    opts.AutoOpen = false;
                })
                .Body(() =>
                {
                    Ajax.Dna().TextArea("TrackbackLinkValue").Width(262).Value(article.TrackbackUrl).Render();
                })
                .Render();
                }
            </li>
        }
        <li>
            @Ajax.Dna().Link("javascript:void(0);").LocText("RES_PERMALINK").Name("PermalinkOpener").ImageIcons(Url.Content("~/Content/Images/icon_link_16.png")).GetHtml()
            @{ 
                Ajax.Dna().Dialog(Html.Global("RES_PERMALINK"))
                            .OpenWith("PermalinkOpener")
                            .Options(opts =>
                            {
                                opts.Width = 300;
                                opts.ShowModal = true;
                                opts.ShowEffect = jQueryEffects.Scale;
                                opts.HideEffect = jQueryEffects.Scale;
                                opts.IsResizable = false;
                                opts.AutoOpen = false;
                            })
                            .Body(() =>
                            {
                                Ajax.Dna().TextArea("PermalinkValue").Width(262).Value(article.PermaLink).Render();
                            })
                            .Render();
            }
        </li>
        @if (((web.IsRoot) && (context.IsAuthorized<DNA.Mvc.Publishing.Controllers.ArticleController>("Edit"))) ||
                                                  (User.IsWebOwner()))
        {
            <li>
                @Ajax.Dna().Link(Url.Action("Edit", "Article", new { website = web.Name, id = Model.ID, Area = "Publishing" })).LocText("RES_EDIT").ImageIcons(Url.Content("~/Content/Images/edit_page.png")).GetHtml()
            </li>
        }
    </ul>
    @{ Html.ForceImageAutoSize("viewContent_bodyArea", -1, 600); }
</div>
